﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Fraktalysator.Forms
{
	partial class PreviewImageForm : ImageDisplayForm
	{
		public PreviewImageForm()
		{
			InitializeComponent();
			this.ImageContainer.BorderStyle = BorderStyle.Fixed3D;
			this.ImageContainer.BackgroundImageLayout = ImageLayout.Zoom;
			if (ArgusLib.Environment.Runtime == ArgusLib.Runtime.Mono)
			{
				this.ClientSizeChanged += PreviewImageForm_ClientSizeChanged;
			}
		}

		void PreviewImageForm_ClientSizeChanged(object sender, EventArgs e)
		{
			if (this.Image != null && this.IsSettingImageContainerSize == true)
			{
				this.ImageSize = this.ImageSize.ChangeRatio(this.Image.Size.GetRatio(), ArgusLib.Drawing.ChangeRatioOptions.DecreaseAreaSize);
			}
		}

		protected override void OnResizeEnd(EventArgs e)
		{
			if (this.Image != null)
			{
				this.ImageSize = this.ImageSize.ChangeRatio(this.Image.Size.GetRatio(), ArgusLib.Drawing.ChangeRatioOptions.DecreaseAreaSize);
			}
			base.OnResizeEnd(e);
		}

		protected override void OnImageChanged(EventArgs e)
		{
			if (this.Image != null/* && ArgusLib.Environment.Runtime != ArgusLib.Runtime.Mono*/)
			{
				this.ImageSize = this.ImageSize.ChangeRatio(this.Image.Size.GetRatio(), ArgusLib.Drawing.ChangeRatioOptions.KeepAreaSize);
			}
			base.OnImageChanged(e);
		}
	}
}
